<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.9.1"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>libevdev: uinput device creation</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
<link href="libevdevdoxygen.css" rel="stylesheet" type="text/css"/>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="doxy-boot.js"></script>
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand">libevdev 1.13.0</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel panel-default" style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">uinput device creation</div>  </div>
</div><!--header-->
<div class="contents">

<p>Creation of uinput devices based on existing libevdev devices.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaf14b21301bac9d79c20e890172873b96"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a> (const struct libevdev *dev, int uinput_fd, struct libevdev_uinput **uinput_dev)</td></tr>
<tr class="memdesc:gaf14b21301bac9d79c20e890172873b96"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a uinput device based on the given libevdev device.  <a href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">More...</a><br /></td></tr>
<tr class="separator:gaf14b21301bac9d79c20e890172873b96"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a> (struct libevdev_uinput *uinput_dev)</td></tr>
<tr class="memdesc:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroy a previously created uinput device and free associated memory.  <a href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">More...</a><br /></td></tr>
<tr class="separator:ga9dfa58a84eb4c6b97107dcf3fa621329"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d">libevdev_uinput_get_fd</a> (const struct libevdev_uinput *uinput_dev)</td></tr>
<tr class="memdesc:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the file descriptor used to create this uinput device.  <a href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d">More...</a><br /></td></tr>
<tr class="separator:ga9cd7fb14a96d4cc14d3dffdcead84c5d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaacca93061fce57cec0ce3c52e443a427"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427">libevdev_uinput_get_syspath</a> (struct libevdev_uinput *uinput_dev)</td></tr>
<tr class="memdesc:gaacca93061fce57cec0ce3c52e443a427"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the syspath representing this uinput device.  <a href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427">More...</a><br /></td></tr>
<tr class="separator:gaacca93061fce57cec0ce3c52e443a427"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="memItemLeft" align="right" valign="top">const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2">libevdev_uinput_get_devnode</a> (struct libevdev_uinput *uinput_dev)</td></tr>
<tr class="memdesc:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the device node representing this uinput device.  <a href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2">More...</a><br /></td></tr>
<tr class="separator:ga4c595bcda748b08561e2819fe9b7c2d2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a> (const struct libevdev_uinput *uinput_dev, unsigned int type, unsigned int code, int value)</td></tr>
<tr class="memdesc:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Post an event through the uinput device.  <a href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">More...</a><br /></td></tr>
<tr class="separator:ga4c3c2f5fcd315a28a067f53b9f855fe7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Creation of uinput devices based on existing libevdev devices. </p>
<p>These functions help to create uinput devices that emulate libevdev devices. In the simplest form it serves to duplicate an existing device:</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div>
<div class="line"><span class="keywordtype">int</span> fd, uifd;</div>
<div class="line"><span class="keyword">struct </span>libevdev *dev;</div>
<div class="line"><span class="keyword">struct </span>libevdev_uinput *uidev;</div>
<div class="line"> </div>
<div class="line">fd = open(<span class="stringliteral">&quot;/dev/input/event0&quot;</span>, O_RDONLY);</div>
<div class="line"><span class="keywordflow">if</span> (fd &lt; 0)</div>
<div class="line">    <span class="keywordflow">return</span> -errno;</div>
<div class="line"> </div>
<div class="line">err = <a class="code" href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">libevdev_new_from_fd</a>(fd, &amp;dev);</div>
<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
<div class="line">    <span class="keywordflow">return</span> err;</div>
<div class="line"> </div>
<div class="line">uifd = open(<span class="stringliteral">&quot;/dev/uinput&quot;</span>, O_RDWR);</div>
<div class="line"><span class="keywordflow">if</span> (uifd &lt; 0)</div>
<div class="line">    <span class="keywordflow">return</span> -errno;</div>
<div class="line"> </div>
<div class="line">err = <a class="code" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a>(dev, uifd, &amp;uidev);</div>
<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
<div class="line">    <span class="keywordflow">return</span> err;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// post a REL_X event</span></div>
<div class="line">err = <a class="code" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a>(uidev, EV_REL, REL_X, -1);</div>
<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
<div class="line">    <span class="keywordflow">return</span> err;</div>
<div class="line">err = <a class="code" href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a>(uidev, EV_SYN, SYN_REPORT, 0);</div>
<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
<div class="line">    <span class="keywordflow">return</span> err;</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a>(uidev);</div>
<div class="line"><a class="code" href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a>(dev);</div>
<div class="line">close(uifd);</div>
<div class="line">close(fd);</div>
<div class="ttc" id="agroup__init_html_ga89bb5bce1c23e293293484b05b12aaf4"><div class="ttname"><a href="group__init.html#ga89bb5bce1c23e293293484b05b12aaf4">libevdev_new_from_fd</a></div><div class="ttdeci">int libevdev_new_from_fd(int fd, struct libevdev **dev)</div><div class="ttdoc">Initialize a new libevdev device from the given fd.</div></div>
<div class="ttc" id="agroup__init_html_gacd9fe760d15be25fc99ce469034bd78c"><div class="ttname"><a href="group__init.html#gacd9fe760d15be25fc99ce469034bd78c">libevdev_free</a></div><div class="ttdeci">void libevdev_free(struct libevdev *dev)</div><div class="ttdoc">Clean up and free the libevdev struct.</div></div>
<div class="ttc" id="agroup__uinput_html_ga4c3c2f5fcd315a28a067f53b9f855fe7"><div class="ttname"><a href="group__uinput.html#ga4c3c2f5fcd315a28a067f53b9f855fe7">libevdev_uinput_write_event</a></div><div class="ttdeci">int libevdev_uinput_write_event(const struct libevdev_uinput *uinput_dev, unsigned int type, unsigned int code, int value)</div><div class="ttdoc">Post an event through the uinput device.</div></div>
<div class="ttc" id="agroup__uinput_html_ga9dfa58a84eb4c6b97107dcf3fa621329"><div class="ttname"><a href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a></div><div class="ttdeci">void libevdev_uinput_destroy(struct libevdev_uinput *uinput_dev)</div><div class="ttdoc">Destroy a previously created uinput device and free associated memory.</div></div>
<div class="ttc" id="agroup__uinput_html_gaf14b21301bac9d79c20e890172873b96"><div class="ttname"><a href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a></div><div class="ttdeci">int libevdev_uinput_create_from_device(const struct libevdev *dev, int uinput_fd, struct libevdev_uinput **uinput_dev)</div><div class="ttdoc">Create a uinput device based on the given libevdev device.</div></div>
</div><!-- fragment --><p>Alternatively, a device can be constructed from scratch:</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> err;</div>
<div class="line"><span class="keyword">struct </span>libevdev *dev;</div>
<div class="line"><span class="keyword">struct </span>libevdev_uinput *uidev;</div>
<div class="line"> </div>
<div class="line">dev = <a class="code" href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a>();</div>
<div class="line"><a class="code" href="group__kernel.html#gae5dcdb7678cdc9be4ab1989725b4ed32">libevdev_set_name</a>(dev, <span class="stringliteral">&quot;test device&quot;</span>);</div>
<div class="line"><a class="code" href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a>(dev, EV_REL);</div>
<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_REL, REL_X, NULL);</div>
<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_REL, REL_Y, NULL);</div>
<div class="line"><a class="code" href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a>(dev, EV_KEY);</div>
<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_LEFT, NULL);</div>
<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_MIDDLE, NULL);</div>
<div class="line"><a class="code" href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a>(dev, EV_KEY, BTN_RIGHT, NULL);</div>
<div class="line"> </div>
<div class="line">err = <a class="code" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96">libevdev_uinput_create_from_device</a>(dev,</div>
<div class="line">                                         <a class="code" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>,</div>
<div class="line">                                         &amp;uidev);</div>
<div class="line"><span class="keywordflow">if</span> (err != 0)</div>
<div class="line">    <span class="keywordflow">return</span> err;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// ... do something ...</span></div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329">libevdev_uinput_destroy</a>(uidev);</div>
<div class="ttc" id="agroup__init_html_ga332c8ee260b4ef864345abe5d04e820c"><div class="ttname"><a href="group__init.html#ga332c8ee260b4ef864345abe5d04e820c">libevdev_new</a></div><div class="ttdeci">struct libevdev * libevdev_new(void)</div><div class="ttdoc">Initialize a new libevdev device.</div></div>
<div class="ttc" id="agroup__kernel_html_ga51cfda33fd526549046399aadd764fca"><div class="ttname"><a href="group__kernel.html#ga51cfda33fd526549046399aadd764fca">libevdev_enable_event_code</a></div><div class="ttdeci">int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data)</div><div class="ttdoc">Forcibly enable an event code on this device, even if the underlying device does not support it.</div></div>
<div class="ttc" id="agroup__kernel_html_ga59ef78b1557f9543d0060ab25b0167ca"><div class="ttname"><a href="group__kernel.html#ga59ef78b1557f9543d0060ab25b0167ca">libevdev_enable_event_type</a></div><div class="ttdeci">int libevdev_enable_event_type(struct libevdev *dev, unsigned int type)</div><div class="ttdoc">Forcibly enable an event type on this device, even if the underlying device does not support it.</div></div>
<div class="ttc" id="agroup__kernel_html_gae5dcdb7678cdc9be4ab1989725b4ed32"><div class="ttname"><a href="group__kernel.html#gae5dcdb7678cdc9be4ab1989725b4ed32">libevdev_set_name</a></div><div class="ttdeci">void libevdev_set_name(struct libevdev *dev, const char *name)</div><div class="ttdoc">Change the device's name as returned by libevdev_get_name().</div></div>
<div class="ttc" id="alibevdev-uinput_8h_html_a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad"><div class="ttname"><a href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a></div><div class="ttdeci">@ LIBEVDEV_UINPUT_OPEN_MANAGED</div><div class="ttdoc">let libevdev open and close /dev/uinput</div><div class="ttdef"><b>Definition:</b> libevdev-uinput.h:114</div></div>
</div><!-- fragment --> <h2 class="groupheader">Function Documentation</h2>
<a id="gaf14b21301bac9d79c20e890172873b96"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf14b21301bac9d79c20e890172873b96">&#9670;&nbsp;</a></span>libevdev_uinput_create_from_device()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libevdev_uinput_create_from_device </td>
          <td>(</td>
          <td class="paramtype">const struct libevdev *&#160;</td>
          <td class="paramname"><em>dev</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>uinput_fd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct libevdev_uinput **&#160;</td>
          <td class="paramname"><em>uinput_dev</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a uinput device based on the given libevdev device. </p>
<p>The uinput device will be an exact copy of the libevdev device, minus the bits that uinput doesn't allow to be set.</p>
<p>If uinput_fd is <a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>, <a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96" title="Create a uinput device based on the given libevdev device.">libevdev_uinput_create_from_device()</a> will open <code>/dev/uinput</code> in read/write mode and manage the file descriptor. Otherwise, uinput_fd must be opened by the caller and opened with the appropriate permissions.</p>
<p>The device's lifetime is tied to the uinput file descriptor, closing it will destroy the uinput device. You should call <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> before closing the file descriptor to free allocated resources. A file descriptor can only create one uinput device at a time; the second device will fail with -EINVAL.</p>
<p>You don't need to keep the file descriptor variable around, <a class="el" href="group__uinput.html#ga9cd7fb14a96d4cc14d3dffdcead84c5d" title="Return the file descriptor used to create this uinput device.">libevdev_uinput_get_fd()</a> will return it when needed.</p>
<dl class="section note"><dt>Note</dt><dd>Due to limitations in the uinput kernel module, REP_DELAY and REP_PERIOD will default to the kernel defaults, not to the ones set in the source device.</dd>
<dd>
On FreeBSD, if the UI_GET_SYSNAME ioctl() fails, there is no other way to get a device, and the function call will fail.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir"></td><td class="paramname">dev</td><td>The device to duplicate </td></tr>
    <tr><td class="paramdir"></td><td class="paramname">uinput_fd</td><td><a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a> or a file descriptor to <code>/dev/uinput</code>, </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">uinput_dev</td><td>The newly created libevdev device.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success or a negative errno on failure. On failure, the value of uinput_dev is unmodified.</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy</a> </dd></dl>

</div>
</div>
<a id="ga9dfa58a84eb4c6b97107dcf3fa621329"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9dfa58a84eb4c6b97107dcf3fa621329">&#9670;&nbsp;</a></span>libevdev_uinput_destroy()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void libevdev_uinput_destroy </td>
          <td>(</td>
          <td class="paramtype">struct libevdev_uinput *&#160;</td>
          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destroy a previously created uinput device and free associated memory. </p>
<p>If the device was opened with <a class="el" href="libevdev-uinput_8h.html#a6546acd3e4fe75a74d91eebf9bbd3d03adcf2d4de38844ee3a8c830bc3285afad">LIBEVDEV_UINPUT_OPEN_MANAGED</a>, <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> also closes the file descriptor. Otherwise, the fd is left as-is and must be closed by the caller.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga4c595bcda748b08561e2819fe9b7c2d2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4c595bcda748b08561e2819fe9b7c2d2">&#9670;&nbsp;</a></span>libevdev_uinput_get_devnode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char* libevdev_uinput_get_devnode </td>
          <td>(</td>
          <td class="paramtype">struct libevdev_uinput *&#160;</td>
          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the device node representing this uinput device. </p>
<p>This relies on <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> to provide a valid syspath. See <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> for more details.</p>
<dl class="section note"><dt>Note</dt><dd>This function may return NULL. libevdev may have to guess the syspath and the device node. See <a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath()</a> for details.</dd>
<dd>
On FreeBSD, this function can not return NULL. libudev uses the UI_GET_SYSNAME ioctl to get the device node on this platform and if that fails, the call to <a class="el" href="group__uinput.html#gaf14b21301bac9d79c20e890172873b96" title="Create a uinput device based on the given libevdev device.">libevdev_uinput_create_from_device()</a> fails.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The device node for this device, in the form of /dev/input/eventN</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#gaacca93061fce57cec0ce3c52e443a427" title="Return the syspath representing this uinput device.">libevdev_uinput_get_syspath</a> </dd></dl>

</div>
</div>
<a id="ga9cd7fb14a96d4cc14d3dffdcead84c5d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9cd7fb14a96d4cc14d3dffdcead84c5d">&#9670;&nbsp;</a></span>libevdev_uinput_get_fd()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libevdev_uinput_get_fd </td>
          <td>(</td>
          <td class="paramtype">const struct libevdev_uinput *&#160;</td>
          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the file descriptor used to create this uinput device. </p>
<p>This is the fd pointing to <b>/dev/uinput</b>. This file descriptor may be used to write events that are emitted by the uinput device. Closing this file descriptor will destroy the uinput device, you should call <a class="el" href="group__uinput.html#ga9dfa58a84eb4c6b97107dcf3fa621329" title="Destroy a previously created uinput device and free associated memory.">libevdev_uinput_destroy()</a> first to free allocated resources.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The file descriptor used to create this device </dd></dl>

</div>
</div>
<a id="gaacca93061fce57cec0ce3c52e443a427"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaacca93061fce57cec0ce3c52e443a427">&#9670;&nbsp;</a></span>libevdev_uinput_get_syspath()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">const char* libevdev_uinput_get_syspath </td>
          <td>(</td>
          <td class="paramtype">struct libevdev_uinput *&#160;</td>
          <td class="paramname"><em>uinput_dev</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Return the syspath representing this uinput device. </p>
<p>If the UI_GET_SYSNAME ioctl is not available, libevdev makes an educated guess. The UI_GET_SYSNAME ioctl is available since Linux 3.15.</p>
<p>The syspath returned is the one of the input node itself (e.g. /sys/devices/virtual/input/input123), not the syspath of the device node returned with <a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2" title="Return the device node representing this uinput device.">libevdev_uinput_get_devnode()</a>.</p>
<dl class="section note"><dt>Note</dt><dd>This function may return NULL if UI_GET_SYSNAME is not available. In that case, libevdev uses ctime and the device name to guess devices. To avoid false positives, wait at least 1.5s between creating devices that have the same name.</dd>
<dd>
FreeBSD does not have sysfs, on FreeBSD this function always returns NULL.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The syspath for this device, including the preceding /sys</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__uinput.html#ga4c595bcda748b08561e2819fe9b7c2d2" title="Return the device node representing this uinput device.">libevdev_uinput_get_devnode</a> </dd></dl>

</div>
</div>
<a id="ga4c3c2f5fcd315a28a067f53b9f855fe7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4c3c2f5fcd315a28a067f53b9f855fe7">&#9670;&nbsp;</a></span>libevdev_uinput_write_event()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int libevdev_uinput_write_event </td>
          <td>(</td>
          <td class="paramtype">const struct libevdev_uinput *&#160;</td>
          <td class="paramname"><em>uinput_dev</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>type</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned int&#160;</td>
          <td class="paramname"><em>code</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Post an event through the uinput device. </p>
<p>It is the caller's responsibility that any event sequence is terminated with an EV_SYN/SYN_REPORT/0 event. Otherwise, listeners on the device node will not see the events until the next EV_SYN event is posted.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">uinput_dev</td><td>A previously created uinput device. </td></tr>
    <tr><td class="paramname">type</td><td>Event type (EV_ABS, EV_REL, etc.) </td></tr>
    <tr><td class="paramname">code</td><td>Event code (ABS_X, REL_Y, etc.) </td></tr>
    <tr><td class="paramname">value</td><td>The event value </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>0 on success or a negative errno on error </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.9.1
</small></address>
</body>
</html>
